<template>


   <SearchTablePage :search-config="baseTableSearchModel" :table-config="baseTableModel" />

</template>

<script lang="ts" setup>
defineOptions({
   name: 'SupplierInfoBasePageData',   //全局别名
   title: '表格页',   //标题
});
// 接口
import SupplierInfoBaseApi from '/@/api/webPath/SupplierInfoBaseApi.ts';


import FORM_FIELD_TYPE from '/@/constants/FormFieldType';
import VDialog from '/@/utils/dialogUtil.ts'

const router = useRouter();
const baseTable = ref(null as any);
const baseTableSearch = ref(null as any);
const editRef = ref<any>(null);

// 表格搜索初始化searchModel
const baseTableSearchModel = ref({
   columnCount: 4,
   expandLimit: 6,
   autoFit: true,
   columnWidth: '300px',
   labelPosition: 'right',
   labelWidth: '100px',
   items: [ //搜索项初始化

      {
         label: "名称",
         field: "supplierName",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "联系人",
         field: "supplinerContacts",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "联系电话",
         field: "supplinerPhone",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "省id",
         field: "supplierProvinceId",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "市id",
         field: "supplierCityId",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "区id",
         field: "supplierCareaId",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "省",
         field: "supplierProvinceName",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "市",
         field: "supplierCityName",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "区",
         field: "supplierCareaName",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "地址",
         field: "supplierAdd",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "统一社会信用代码",
         field: "creditCode",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "统一社会信用代码签发日期",
         field: "creditSignDate",
         clearable: true,
         type: FORM_FIELD_TYPE.DATE_RANGE,
         placeholder: "请输入",

         config: {
            props: {   //日期精度配置
               type: "daterange",
               startPlaceholder: "开始日期",
               endPlaceholder: "结束日期",
               format: "YYYY-MM-DD",
            }
         },
      },

      {
         label: "统一社会信用代码许可证类型",
         field: "creditType",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "统一社会信用代码许可证类型名称",
         field: "creditTypeName",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "经营许可证编码",
         field: "businessCode",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "经营许可证签发日期",
         field: "businessSignDate",
         clearable: true,
         type: FORM_FIELD_TYPE.DATE_RANGE,
         placeholder: "请输入",

         config: {
            props: {   //日期精度配置
               type: "daterange",
               startPlaceholder: "开始日期",
               endPlaceholder: "结束日期",
               format: "YYYY-MM-DD",
            }
         },
      },

      {
         label: "经营许可有效期",
         field: "businessEffectiveDate",
         clearable: true,
         type: FORM_FIELD_TYPE.DATE_RANGE,
         placeholder: "请输入",

         config: {
            props: {   //日期精度配置
               type: "daterange",
               startPlaceholder: "开始日期",
               endPlaceholder: "结束日期",
               format: "YYYY-MM-DD",
            }
         },
      },

      {
         label: "经营许可类型",
         field: "businessType",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "经营许可类型名称",
         field: "businessTypeName",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "生产许可证编码",
         field: "produceCode",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "生产许可证签发日期",
         field: "produceSignDate",
         clearable: true,
         type: FORM_FIELD_TYPE.DATE_RANGE,
         placeholder: "请输入",

         config: {
            props: {   //日期精度配置
               type: "daterange",
               startPlaceholder: "开始日期",
               endPlaceholder: "结束日期",
               format: "YYYY-MM-DD",
            }
         },
      },

      {
         label: "生产许可有效期",
         field: "produceEffectiveDate",
         clearable: true,
         type: FORM_FIELD_TYPE.DATE_RANGE,
         placeholder: "请输入",

         config: {
            props: {   //日期精度配置
               type: "daterange",
               startPlaceholder: "开始日期",
               endPlaceholder: "结束日期",
               format: "YYYY-MM-DD",
            }
         },
      },

      {
         label: "生产许可类型",
         field: "produceType",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "生产许可类型名称",
         field: "produceTypeName",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "生产许可产品类别",
         field: "produceClass",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "生产许可类别编码",
         field: "produceClassCode",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "生产许可类别名称",
         field: "produceClassName",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "生产许可品种明细",
         field: "produceClassDetail",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "创建人",
         field: "creator",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      {
         label: "修改人",
         field: "reviser",
         clearable: true,
         type: FORM_FIELD_TYPE.INPUT,

         placeholder: "请输入",

      },

      // {
      //    label: "排序",
      //    field: "sort",
      //    clearable: true,
      //    type: FORM_FIELD_TYPE.INPUT,

      //    placeholder: "请输入",

      // },

      {
         label: "创建时间",
         field: "create_time",
         clearable: true,
         type: FORM_FIELD_TYPE.DATE_RANGE,
         placeholder: "请输入",

         config: {
            props: {   //日期精度配置
               type: "daterange",
               startPlaceholder: "开始日期",
               endPlaceholder: "结束日期",
               format: "YYYY-MM-DD",
            }
         },
      },

   ],

   buttons: [    //功能区域
      {
         name: "下载",
         buttonClass: 'primary',
         width: 100,
         click: ({ row, handlers }) => {   //暴露的方法钩子
            SupplierInfoBaseApi.pageDataXls(handlers.getRequestParams(), handlers.getXlsTitle())
         }
      },

      {
         name: "新增",
         buttonClass: 'primary',
         width: 100,
         click: ({ row, handlers }) => {        // 点击回调事件方法钩子，  点击触发

            VDialog.open({
               title: '新增',

               content: { //内容初始形式
                  type: 'component', //text:"",预留文本
                  name: '/supplierInfoBase/edit',
                  query: {},

               },

               callBack: (data: any) => {
                  handlers.refresh()
               },
               onClose: () => {
                  console.log("对话框已关闭");
               },
            });

         },
      },

      {
         name: "导入",
         buttonClass: 'primary',
         width: 100,
         click: ({ row, handlers }) => {   //暴露的方法钩子
            //  CompanyInfoApi.pageDataXls( handlers.getRequestParams(),handlers.getXlsTitle())
            VDialog.open({
               title: '数据导入',
               content: { //内容初始形式
                  type: 'component', //text:"",预留文本
                  name: '/supplierInfoBase/upload',
                  // query: { companyInfoId: row.id },
               },
               config: {
                  doUpload: SupplierInfoBaseApi.uploadExcel,
                  templateType: "company_template_type_1",
                  tips: '注：请先点击“下载模版”按钮下载模版，按照模版填写数据，再进行导入。'
               },
               callBack: (data: any) => {
                  // handlers.refresh()
                  console.log("upload recived data:", data)
               },
               onClose: () => {
                  console.log("对话框已关闭");
               },
            })
         }
      },
      {
         name: "批量删除",
         buttonClass: 'danger',
         width: 100,
         isShow: (row: any) => {
            return false;
         },
         click: () => {   //暴露的方法钩子
            console.log(baseTable.value.getSelection());
         },
      },
   ]
})
// 表格初始化Model
const baseTableModel = ref({
   border: true,
   pagination: true,
   inline: true,
   selectable: true,
   isFullscreen: false,
   minWidth: '200px',
   data: {    //table  初始化
      current: 1,
      size: 10,
      total: 100,
      data: []
   },
   requestData: { api: SupplierInfoBaseApi.getPageData, query: {} },   //数据源 参数有效性： 'steady|transient'
   columns: [
      {
         label: "id",
         field: "id",
         width: 100,
         tooltip: true,
      },
      // {
      //    label: "排序",
      //    field: "sort",
      //    width: 120,
      //    tooltip: true,
      // },
      {
         label: "名称",
         field: "supplierName",
         width: 180,
         tooltip: true,
      },
      {
         label: "联系人",
         field: "supplinerContacts",
         width: 180,
         tooltip: true,
      },
      {
         label: "联系电话",
         field: "supplinerPhone",
         width: 180,
         tooltip: true,
      },
      {
         label: "省id",
         field: "supplierProvinceId",
         width: 120,
         tooltip: true,
      },
      {
         label: "市id",
         field: "supplierCityId",
         width: 120,
         tooltip: true,
      },
      {
         label: "区id",
         field: "supplierCareaId",
         width: 120,
         tooltip: true,
      },
      {
         label: "省",
         field: "supplierProvinceName",
         width: 180,
         tooltip: true,
      },
      {
         label: "市",
         field: "supplierCityName",
         width: 180,
         tooltip: true,
      },
      {
         label: "区",
         field: "supplierCareaName",
         width: 180,
         tooltip: true,
      },
      {
         label: "地址",
         field: "supplierAdd",
         width: 180,
         tooltip: true,
      },
      {
         label: "统一社会信用代码",
         field: "creditCode",
         width: 180,
         tooltip: true,
      },
      {
         label: "统一社会信用代码签发日期",
         field: "creditSignDate",
         width: 200,
         tooltip: true,
      },
      {
         label: "统一社会信用代码许可证类型",
         field: "creditType",
         width: 180,
         tooltip: true,
      },
      {
         label: "统一社会信用代码许可证类型名称",
         field: "creditTypeName",
         width: 180,
         tooltip: true,
      },
      {
         label: "经营许可证编码",
         field: "businessCode",
         width: 180,
         tooltip: true,
      },
      {
         label: "经营许可证签发日期",
         field: "businessSignDate",
         width: 200,
         tooltip: true,
      },
      {
         label: "经营许可有效期",
         field: "businessEffectiveDate",
         width: 200,
         tooltip: true,
      },
      {
         label: "经营许可类型",
         field: "businessType",
         width: 180,
         tooltip: true,
      },
      {
         label: "经营许可类型名称",
         field: "businessTypeName",
         width: 180,
         tooltip: true,
      },
      {
         label: "生产许可证编码",
         field: "produceCode",
         width: 180,
         tooltip: true,
      },
      {
         label: "生产许可证签发日期",
         field: "produceSignDate",
         width: 200,
         tooltip: true,
      },
      {
         label: "生产许可有效期",
         field: "produceEffectiveDate",
         width: 200,
         tooltip: true,
      },
      {
         label: "生产许可类型",
         field: "produceType",
         width: 180,
         tooltip: true,
      },
      {
         label: "生产许可类型名称",
         field: "produceTypeName",
         width: 180,
         tooltip: true,
      },
      {
         label: "生产许可产品类别",
         field: "produceClass",
         width: 180,
         tooltip: true,
      },
      {
         label: "生产许可类别编码",
         field: "produceClassCode",
         width: 180,
         tooltip: true,
      },
      {
         label: "生产许可类别名称",
         field: "produceClassName",
         width: 180,
         tooltip: true,
      },
      {
         label: "生产许可品种明细",
         field: "produceClassDetail",
         width: 180,
         tooltip: true,
      },
      {
         label: "创建人",
         field: "creator",
         width: 180,
         tooltip: true,
      },
      {
         label: "修改人",
         field: "reviser",
         width: 180,
         tooltip: true,
      },
      {
         label: "创建时间",
         field: "create_time",
         width: 200,
         tooltip: true,
      },
      {
         label: "更新时间",
         field: "update_time",
         width: 200,
         tooltip: true,
      },
   ],


   actions: [
      {
         name: "详情",

         buttonClass: 'primary',
         buttonType: 'text',
         click: ({ row, index, handlers }) => {

            //router.push({name: 'CompanyInfoDetail',})
            VDialog.open({
               title: '详情',
               content: { //内容初始形式
                  type: 'component', //text:"",预留文本
                  name: '/supplierInfoBase/detail',
                  query: { supplierInfoBaseId: row.id },

               },
               callBack: (data: any) => {
                  handlers.refresh()
               },
               onClose: () => {
                  console.log("对话框已关闭");
               },
            });
         },
         isShow: (row: object) => {
            return true;
         },
         fixed: 'right'
      },
      {
         name: "编辑",
         buttonClass: 'primary',   //按钮颜色控制
         buttonType: 'text',      // 按钮风格   text  link  button
         isShow: (row: object) => {  //根据业务做动态隐藏张氏
            return true
         },
         click: ({ row, index, handlers }) => {        // 点击回调事件方法钩子，  点击触发

            VDialog.open({
               title: '编辑',
               content: { //内容初始形式
                  type: 'component', //text:"",预留文本
                  name: '/supplierInfoBase/edit',
                  query: { supplierInfoBaseId: row.id },

               },

               callBack: (data: any) => {
                  handlers.refresh()
               },
               onClose: () => {
                  console.log("对话框已关闭");
               },
            });

         },
         fixed: 'right'
      },

      {
         name: "删除",
         buttonClass: 'danger',
         buttonType: 'text',
         fixed: 'right',
         click: ({ row, index, handlers }) => {

            $baseConfirm('您确定要删除当前项吗', null, async () => {

               const { message } = await SupplierInfoBaseApi.del({ supplierInfoBaseIds: row.id })
               $baseMessage(message, 'success', 'vab-hey-message-success');

               handlers.refresh()

            })

         }
      },

   ]

})



onActivated(() => {
})



</script>
